﻿using Basic.HrDAL;
using Basic.HrModel.SignatureFile;
using Basic.HrRemoteModel.EmpSignatureFile.Model;
using WeDonekRpc.Helper;
using WeDonekRpc.Model;

namespace Basic.HrCollect.Impl
{
    internal class EmpSignatureFileCollect : IEmpSignatureFileCollect
    {
        private readonly IEmpSignatureFileDAL _BasicDAL;

        public EmpSignatureFileCollect ( IEmpSignatureFileDAL basicDAL )
        {
            this._BasicDAL = basicDAL;
        }
        public Result[] Query<Result> ( long empId, SignQueryParam query, IBasicPage paging, out int count ) where Result : class
        {
            return this._BasicDAL.Query<Result>(empId, query, paging, out count);
        }
        public long Add ( SignatureFileAdd add )
        {
            return this._BasicDAL.Add(add);
        }
        public void Drop ( EmpSignatureFile file )
        {
            if ( file.IsDrop )
            {
                return;
            }
            this._BasicDAL.Drop(file.Id);
        }
        public SignFileItem[] Gets ( long empId )
        {
            return this._BasicDAL.Gets<SignFileItem>(a => a.EmpId == empId && a.IsDrop == false).OrderByDescending(a => a.EndTime).ToArray();
        }
        public Result[] Gets<Result> ( long[] ids ) where Result : class, new()
        {
            return this._BasicDAL.Gets<Result>(a => ids.Contains(a.Id));
        }
        public EmpSignatureFile Get ( long id )
        {
            return this._BasicDAL.Get<EmpSignatureFile>(id);
        }
        public SignFilePwd GetPwd ( long id )
        {
            return this._BasicDAL.Get<SignFilePwd>(id);
        }
    }
}
